<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Jedrzej\Pimpable\PimpableTrait;

class ArticleCategory extends Model
{
    use HasFactory;
    use PimpableTrait;
    use SoftDeletes;
    /**
     * 可批量赋值的字段
     */
    public  $fillable = [
      'title',
      'inter',
      'image',
      'sort',
      'pid',
      'status',
      'is_del',
      'is_hidden',
    ];
    /**
     * 默认倒序排序
     */
    protected $defaultSortCriteria = ['id,desc'];
    /**
     * 可排序字段
     */
    public $sortable = [
        'id',
    ];

    /**
     * 可搜索的字段
     */
    public $searchable = [
        'title',
        'inter',
        'pid',
    ];

    /**
     *关联的文章
     */
    public function article(){
        return $this->hasMany(Article::class,'category_id','id');
    }
}
